#include "Condition.h"
#include "vec3.h"
#include <math.h>

#define EPSILON 0.01f

bool Condition::EvaluateValues(value val)
{
	switch(val.type)
	{
	case tBOOLEAN:
		if (val.b_value == active.b_value) return true;
		return false;
		break;
	case tINTEGER:
		if (val.u_value == active.u_value) return true;
		return false;
		break;
	case tFLOATING:
		if (fabs(val.f_value - active.f_value) < EPSILON) return true;
		return false;
		break;
	case tVECTOR3:
		if (fabs(vec3f(vec3f(val.v_value[0], val.v_value[1], val.v_value[2]) - vec3f(active.v_value[0], active.v_value[1], active.v_value[2])).magnitude()) < EPSILON) return true;
		return false;
		break;
	case tPOINTER:
		if (val.p_value == active.p_value) return true; // check if objects have same memory address...
		return false;
		break;
	default:
		return false;
		break;
	};
	return false;
}